package com.service.impl;

import com.dao.MembertypeDao;
import com.dto.DTO;
import com.dto.MessageEnum;
import com.entity.Membertype;
import com.service.MembertypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

@Service("MembertypeService")
public class MembertypeServiceImpl implements MembertypeService {
    @Resource
    MembertypeDao membertypeDao;
    @Override
    public DTO<Membertype> getAllMembertypes() {
        List<Membertype> membertypes = membertypeDao.getAllMembertypes();
        MessageEnum messageEnum  = Optional.ofNullable(membertypes).isPresent()?MessageEnum.GETMEMBERTYPESUCCESS:MessageEnum.GETMEMBERTYPEFAIL;
        return new DTO<Membertype>(messageEnum.getCode(),messageEnum.getMessage(),membertypes);
    }
}
